<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>graph_2_mat</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab function</center>
    <div align="right">Last update : September 1995</div>
    <p>
      <b>graph_2_mat</b> -  node-arc or node-node incidence matrix of a graph</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>a = graph_2_mat(g,mat)  </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>g</b>
        </tt>: graph list</li>
      <li>
        <tt>
          <b>mat</b>
        </tt>: optional string, 'node-arc' or 'node-node' matrix</li>
      <li>
        <tt>
          <b>a</b>
        </tt>: sparse node-arc or node-node incidence matrix</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
      <tt>
        <b>graph_2_mat</b>
      </tt> computes the node-arc or the node-node incidence matrix 
    corresponding
    to the graph <tt>
        <b>g</b>
      </tt>.</p>
    <p>
    If the optional argument <tt>
        <b>mat</b>
      </tt> is omitted or is the string 
    <tt>
        <b>'node-arc'</b>
      </tt>, the node-arc matrix is computed. If <tt>
        <b>mat</b>
      </tt> is the string
    <tt>
        <b>'node-node'</b>
      </tt>, the node-node matrix is computed.</p>
    <p>
    If <tt>
        <b>n</b>
      </tt> is the number of nodes of the graph and 
    <tt>
        <b>m</b>
      </tt> is the number of edges of the graph, the node-arc matrix is a Scilab 
    sparse matrix of size <tt>
        <b>(n,m)</b>
      </tt>.</p>
    <p>
    It is defined as follows. If the graph is directed:</p>
    <p>
      <tt>
        <b>a(i,j) = +1</b>
      </tt> if node <tt>
        <b>i</b>
      </tt> is the tail of arc <tt>
        <b>j</b>
      </tt>
    </p>
    <p>
      <tt>
        <b>a(i,j) = -1</b>
      </tt> if node <tt>
        <b>i</b>
      </tt> is the head of arc <tt>
        <b>j</b>
      </tt>
    </p>
    <p>
    If the graph is undirected:</p>
    <p>
      <tt>
        <b>a(i,j) = 1</b>
      </tt> if node <tt>
        <b>i</b>
      </tt> is the tail or the head of arc <tt>
        <b>j</b>
      </tt>
    </p>
    <p>
    If <tt>
        <b>n</b>
      </tt> is the number of nodes of the graph, the node-node matrix is a 
    Scilab sparse matrix of size <tt>
        <b>(n,n)</b>
      </tt>.</p>
    <p>
    It is defined as follows:</p>
    <p>
      <tt>
        <b>a(i,j) = 1</b>
      </tt> if there is an arc from node <tt>
        <b>i</b>
      </tt> to node <tt>
        <b>j</b>
      </tt>
    </p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

g=load_graph(SCI+'/demos/metanet/colored');
a=graph_2_mat(g)
a=graph_2_mat(g,'node-node')
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="mat_2_graph.htm">
        <tt>
          <b>mat_2_graph</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
